-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix for application dialogs opening in wrong displays #7273
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution!
Setting the owner of the sub-dialogs is a good idea, indeed.
I was thinking about the best way to do this, without too much changes. Here is what I came up with:
- The
DialogService
should be able to get the main stage frompublic JabRefDialogService(Window mainWindow, Pane mainPane, PreferencesService preferences) { - Thus, for all dialogs created with the help of the
DialogService
we can easily set the owner. - The dialogs that are currently shown by invoking
dialog.show()
ordialog.showAndWait()
need to be shown via https://github.com/JabRef/jabref/blob/master/src/main/java/org/jabref/gui/JabRefDialogService.java#L267
What do you think?
Hi @tobiasdiez, thanks for the comments.
|
That would work indeed. However, then one needs to pass references of the main stage everywhere (like what you did in the current changes), and that's something I don't really like. Instead, I was proposing to pass references to the DialogService dialogService = ... coming from somewhere
AboutDialogView aboutDialogView = new AboutDialogView();
dialogService.show(aboutDialogView); to show the dialog with the proper owner (set in the dialogservice class). In this way, only the dialogservice needs to know about the main stage. Moreover, there are already a lot of places that have the dialog service floating around, so hopefully less changes are required. |
Sounds good, can you explain how dependency inject is handled in this project, I'm unable to correctly inject |
You can use
This is then usually passed to the ViewModel, which uses it to open a dialog.
But for our purposes here that's not very helpful as there are almost no dialogs created from other dialogs. For actions, the usual pattern is to pass it as a constructor argument, e.g. https://github.com/JabRef/jabref/blob/4cf2fb06d3d876d2043f65ca0e51c3c4185fd05c/src/main/java/org/jabref/gui/undo/UndoRedoAction.java |
What are your thoughts regarding instantiating via the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the Injectior
is actually a very good idea!
@@ -272,4 +273,6 @@ boolean showConfirmationDialogWithOptOutAndWait(String title, String content, | |||
* @return the selected file or an empty {@link Optional} if no file has been selected | |||
*/ | |||
Optional<Path> showFileOpenFromArchiveDialog(Path archivePath) throws IOException; | |||
|
|||
void show(BaseDialog<?> aboutDialogView); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rename it to showCustomDialog
to be coherent with the above method. Or rename that to showAndWait
...yeah maybe the later?
Please also rename the argument, and add a bit of documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rename it to
showCustomDialog
to be coherent with the above method. Or rename that toshowAndWait
...yeah maybe the later?Please also rename the argument, and add a bit of documentation.
Decided to go with showCustomDialog()
as it seems to be more consistent with other methods in that interface.
- Rename DialogService.show() method to showCustomDialog() - Rename showCustomDialog()'s argument - Add documentation to showCustomDialog method - Make createDialog and createDialogWithOptOut non static
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for the quick follow-ups! The code looks good to me!
The added test seems to be failing, I am unable to run the tests locally. Do you have an idea what I might be missing in the test? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Testing javafx code is a bit more involved as you have to start the gui interface, see e.g. https://github.com/JabRef/jabref/blob/c8f7be89ad704065474decb61851e42416caf88d/src/test/java/org/jabref/gui/entryeditor/SourceTabTest.java for an example.
To be honest, here it would be fine not to add a test (although it's always good to have tests of course).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for your PR! LGTM
Thanks for the help and comments. 👍🏾 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
It would be nice if you add some summary and explanation to our devdocs what to do when creating a new dialog, e.g using dialogService to start
https://devdocs.jabref.org/getting-into-the-code/code-howtos#javafx
Please have a look at the markdownlint checkstlye output. Then I would be happy to merge |
* upstream/master: fix checsktyle Fix for application dialogs opening in wrong displays (#7273) Only disable move to file dir when path equals (#7269) Improved detection of long DOI's within text (#7260) Add missing author and fix name Fix style of highlighted checkboxes while searching in preferences (#7258) Updates to institution citation keys (#7210) Bump xmlunit-core from 2.8.1 to 2.8.2 (#7251) Bump classgraph from 4.8.97 to 4.8.98 (#7250) Bump bcprov-jdk15on from 1.67 to 1.68 (#7249) Bump xmlunit-matchers from 2.8.1 to 2.8.2 (#7252) Bump unirest-java from 3.11.06 to 3.11.09 (#7254) Bump org.beryx.jlink from 2.23.0 to 2.23.1 (#7253) Bump pascalgn/automerge-action from v0.12.0 to v0.13.0 (#7255) # Conflicts: # src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java
This PR causes the about dialog not opening a second time (see #7287). Some dialogs can also be opened twice (Customized Entry Types). @faeludire Could you have a look please? |
What:
Why:
Dialog opens in the display the application opened at startup (usually the primary display), regardless of the current position of the application main window
This is a draft to discuss the approach taken.
Fixes #7272